package java8.lambda;

/**
 * https://www.runoob.com/java/java8-lambda-expressions.html
 */
public class Java8Lambda {

    private static int operation(int a, int b, MathOperation mathOperation) {
        return mathOperation.operation(a, b);
    }

    interface MathOperation {
        int operation(int a, int b);
    }

    public static void simpleTest() {
        MathOperation addition = (int a, int b) -> a + b;
        MathOperation subtraction = ((a, b) -> a-b);
        MathOperation multiplication = (int a, int b) -> {return a*b;};
        MathOperation division = (int a, int b) -> a/b;

        System.out.println("10+5="+operation(10, 5, addition));
        System.out.println("10-5="+operation(10, 5, subtraction));
        System.out.println("10*5="+operation(10, 5, multiplication));
        System.out.println("10/5="+operation(10, 5, division));
    }

}
